#pragma once 
#include <unistd.h>
#include <sys/fcntl.h>

enum
{
    SOCKERROR = 1,
    BINDERROR,
    CONNECTERROR,
    WRITEERROR,
    LISTENERROR,
    ACCEPTERROR,
    EPOLLCRATERROR
};

void SetNonBlock(int fd)
{
    int fl = fcntl(fd, F_GETFL);
    if(fl < 0)
    {
        printf("fcntl出错\n");
        return;
    }

    fcntl(fd, F_SETFL, fl | O_NONBLOCK);
}